using System;
using System.Collections;
using System.Collections.Generic;
using Castle.ActiveRecord;

namespace Saffron.Framework.Users
{
    [ActiveRecord]
    public class UserAttribute : ActiveRecordBase
    {
        private int _id;
        private string _name;
        private UserAttributeGroup _group;
        private IList _users = new List<UserAccount>();
        private IList _children = new List<UserAttribute>();

        [PrimaryKey]
        public int Id
        {
            get { return _id; }
            set { _id = value; }
        }

        [Property]
        public string Name
        {
            get { return _name; }
            set { _name = value; }
        }

        [BelongsTo("UserAttributeGroupId", NotNull=true)]
        public UserAttributeGroup Group
        {
            get { return _group; }
            set { _group = value; }
        }


        [HasAndBelongsToMany(typeof(UserAccount), Lazy=true, Table="UserAccountAttribute", ColumnKey="UserAttributeId", ColumnRef="UserAccountId", Inverse=true)]
        public IList Users
        {
            get { return _users; }
            set { _users = value; }
        }

        public static UserAttribute[] FindAll()
        {
            return (UserAttribute[])FindAll(typeof(UserAttribute));
        }

        
    }
}
